<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of sandbox
 *
 * @author chisty
 */
class sandbox {

    //put your code here
    public $url = "";

    public function sandbox($inputURL) {
        $this->url = $inputURL;
        //echo "original";
    }

    public function curlExec() {
        $curlPointer = curl_init();
        // set URL to download
        curl_setopt($curlPointer, CURLOPT_URL, $this->url);

        // user agent:
        curl_setopt($curlPointer, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows Vista; en-US)");

        // remove header? 0 = yes, 1 = no
        curl_setopt($curlPointer, CURLOPT_HEADER, 1);

        // should curl return or print the data? true = return, false = print
        curl_setopt($curlPointer, CURLOPT_RETURNTRANSFER, false);

        // timeout in seconds
        curl_setopt($curlPointer, CURLOPT_TIMEOUT, 20);

        curl_setopt($curlPointer, CURLOPT_COOKIE, "authed=1");

        // download the given URL, and return output
        $output = curl_exec($curlPointer);

        echo $output;
        // close the curl resource, and free system resources
        curl_close($curlPointer);
    }

    function disguise_curl() {
        $curl = curl_init();

        // Setup headers - I used the same headers from Firefox version 2.0.0.6
        // below was split up because php.net said the line was too long. :/
        $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
        $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
        $header[] = "Cache-Control: max-age=0";
        $header[] = "Connection: keep-alive";
        $header[] = "Cookie: authed=1"; // browsers keep this blank.

        curl_setopt($curl, CURLOPT_URL, $this->url);
        curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows Vista; en-US)");
        curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
        curl_setopt($curl, CURLOPT_AUTOREFERER, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);
        curl_setopt($curl, CURLOPT_TIMEOUT, 20);

        $html = curl_exec($curl); // execute the curl command
        curl_close($curl); // close the connection

        echo $html; // and finally, return $html
    }

}

$obj = new sandbox("http://goo.gl/");
$obj->curlExec();
?>
